# -*- coding: utf-8 -*-
# @Time    : 2021/11/21 13:42
# @Author  : super


class File(object):

	def __init__(self,file_name, file_modul, file_encode):
		self.file_name = file_name
		self.file_modul = file_modul
		self.file_encode = file_encode

	def __enter__(self):
		# 定义上文
		self.f = open(self.file_name, self.file_modul, encoding = self.file_encode)
		return self.f

	def __exit__(self, exc_type, exc_val, exc_tb):
		# 定义下文
		self.f.close()


if __name__ == '__main__':
    with File("02_property类属性方法使用.py", "r",file_encode = "utf-8") as f:
	    print(f.read())